﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace IniTechCaash.Domain.Entities
{
    /// <summary>
    /// <see cref="Entity"/> class with additional auditing information. 
    /// </summary>
    public abstract class AuditableEntity : Entity
    {
        /// <summary>
        /// Username of the <see cref="User"/> who created this <see cref="ActivityLog"/>.
        /// </summary>
        [Required]
        [StringLength(256)]
        public string CreatedBy { get; set; }

        /// <summary>
        /// When this <see cref="ActivityLog"/> was created. 
        /// </summary>
        [Required]
        public DateTime CreatedDate { get; set; }

        /// <summary>
        /// Used in the <see cref="DescriptiveId"/>. 
        /// </summary>
        [NotMapped]
        public virtual string Descriptive
        {
            get { throw new NotImplementedException(); }
        }

        /// <summary>
        /// Use this for route-links to <see cref="Entity"/> detail pages. 
        /// </summary>
        [NotMapped]
        public virtual string DescriptiveId
        {
            get { return String.Join("-", Descriptive, Id); }
        }

        /// <summary>
        /// Username of the <see cref="User"/> who most recently this <see cref="ActivityLog"/>.
        /// </summary>
        [Required]
        [StringLength(256)]
        public string LastModifiedBy { get; set; }

        /// <summary>
        /// When this <see cref="ActivityLog"/> was last modified. 
        /// </summary>
        [Required]
        public DateTime LastModifiedDate { get; set; }
    }
}
